-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
merge :: 공지사항 api 연동 #59
base: develop
Are you sure you want to change the base?
Conversation
코멘트 반영하고 있는 건가요? |
try { | ||
const { data } = await instance.get(`${process.env.NEXT_PUBLIC_BASE_URL}/notices`); | ||
const fetchedNotices: NoticeListResponse[] = data.notices.map((notice: any) => ({ | ||
id: notice.id, | ||
title: notice.title, | ||
created_at: new Date(notice.created_at).toISOString() | ||
})); | ||
setNotices(fetchedNotices); | ||
} catch (error: any) { | ||
append({ | ||
title: "", | ||
message: "공지사항 리스트 조회에 실패하였습니다.", | ||
type: "RED", | ||
}); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try catch 말고 then catch문으로 통일 합시다
<h1 className="font-[700] text-[28px]">{noticeDetail?.title}</h1> | ||
<h2 className="font-[500] text-[20px] mt-[20px]">{noticeDetail?.created_at.substring(0, 10)}</h2> | ||
<p className="font-[400] text-[16px] mt-[28px] whitespace-pre-line">{noticeDetail?.content}</p> | ||
<AttachedBox props={noticeDetail?.attachments || []} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noticeDetail 비구조화 할당 합시다.
try { | ||
const response = await axios.get(`${process.env.NEXT_PUBLIC_IMAGE_URL}/${attachment.url}`, { | ||
responseType: 'blob' | ||
}); | ||
|
||
const url = window.URL.createObjectURL(new Blob([response.data])); | ||
const a = document.createElement("a"); | ||
a.href = url; | ||
a.download = file_name_regex(attachment.url); | ||
document.body.appendChild(a); | ||
a.click(); | ||
window.URL.revokeObjectURL(url); | ||
document.body.removeChild(a); | ||
} catch (error) { | ||
console.error('파일 다운로드 에러: ', error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 then catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then catch랑 타입 지정만 해주세요
import { useGetNoticeDetailData } from "@/apis/notice"; | ||
import AttachedBox from "@/components/notice/AttachedBox"; | ||
|
||
export default function NoticeDetailPage(props:any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any 타입은 최대한 피해야 합니다. ts를 쓰는 이유가 없어져요.
title: data.title, | ||
content: data.content, | ||
created_at: new Date(data.created_at).toISOString(), | ||
attachments: data.attachments.map((attachment: any) => ({ | ||
url: attachment.url, | ||
type: attachment.type | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 그냥 data를 반환하면 안되나요? object로 한번 더 감싸는 이유가 무엇인가요?
특이사항
관련 이슈